<?php get_header(); ?>

	<div id="content" class="narrowcolumn">

	<div class="post">

<!--<div style="margin-top:15px;border:solid 1px #e0eeee;"><p>Magnitude 8.8 earthquake in Chile - <a href="http://www.google.com/relief/chileearthquake/">Help and learn more</a></p></div>-->

	<?php
	if ( is_user_logged_in() ){
		echo'<h2>Welcome! ' . $current_user->user_login .'</h2><p>You can use the links in the <strong>green bar</strong> at the top of your screen to get to your blog dashboard.</p>';
		$image_path = get_bloginfo( 'wpurl' )."/avatars/";
		$the_avatar = $image_path.$current_user->ID. ".jpg?" .time();
		if ( file_exists("$avatars_path/$current_user->ID.jpg") ){
			echo '<div style="float:right;margin-top:0;"><img title="'.$current_user->user_login.'" style="margin: 2px; padding: 2px;border: solid 1px #999; width:72px;" src="' . $the_avatar. '" alt="' . $current_user->user_login . '"  /></div>';
		} else {
			//echo '<div style="float:right;margin-top:0;"><a href="http://' . $current_user->user_login . '.bloggles.info/wp-admin/profile.php"><img title="'.$current_user->user_login.'" style="margin: 2px; padding: 2px;border: solid 1px #999;" src="' . $image_path . 'default.jpg" alt="You may upload your photo in your admin panel." /></a></div>';
			echo '<div style="float:right;margin-top:0;">' .get_avatar( $current_user->ID, $current_user->user_email, 16 ) .'</div>';
		}
	} else {
			echo '<div class="post"><h2>Welcome to Blogates! Start blog your life today...</h2>';
			echo '<div class="entry"><p>Blogates.com is free builds your site, organizes and archives your posts, and publishes your thought, journal with no experience in HTML, FTP, or graphic design. You may publish written text, photos, journal, thought, and more with just a single click of your mouse.</p></div></div>';
	}
	?>
	<p>

	<?php 
	if ( is_user_logged_in() ) {
		//echo "<h2>Welcome! " . $current_user->user_login ."</h2>";
		$blogs = get_blogs_of_user( $current_user->ID );

		if ( ! empty($blogs) ) echo '<p>Here are the blogs you already have:</p><ul>'; foreach ( $blogs as $blog ) {
			echo "<li><a href='http://" . $blog->domain . $blog->path . "' title='Visit blog'>" . $blog->blogname . "</a> (<a href='http://" . $blog->domain . $blog->path . "wp-admin/' title='Login to dashboard'>Dashboard</a>)</li>";
		}
		echo "<li><a href='/signup/?ref=registered'>Register another blog &raquo;</a></li>";
	}
	echo '</ul>';
	?>
	</div>

<?php if ( is_human() ) : ?>

<div style="border:solid 0px #FFCC99;padding:10px;-moz-box-shadow:rgba(200,200,200,1) 0 4px 18px;-webkit-box-shadow:rgba(200,200,200,1) 0 4px 18px;-khtml-box-shadow:rgba(200,200,200,1) 0 4px 18px;box-shadow:rgba(200,200,200,1) 0 4px 18px;">
<table><tr><td>
<script type="text/javascript">
google_ad_client = "<?php google_pub_id(); ?>";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text_image";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "00688B";
google_color_url = "808080";
google_color_text = "808080";
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></td><td>
<script type="text/javascript">
google_ad_client = "<?php google_pub_id(); ?>";
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = "250x250_as";
google_ad_type = "text_image";
google_color_border = "ffffff";
google_color_bg = "ffffff";
google_color_link = "00688B";
google_color_url = "808080";
google_color_text = "808080";
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td></tr></table></div>

<?php endif; ?>

<?php
if( file_exists( ABSPATH . WPINC . '/feed.php') ) {
	require_once(ABSPATH . WPINC . '/feed.php');
} else {
	require_once(ABSPATH . WPINC . '/rss.php');
}

$rss = fetch_feed('http://tags.bloggles.info/feed/atom/');

if (!is_wp_error( $rss ) ) :
	$maxitems = $rss->get_item_quantity(10);
    $rss_items = $rss->get_items(0, $maxitems);
endif;

?>

<div class="post"><h2>Latest Journal</h2>

    <?php if ($maxitems == 0) echo '<!--no news-->';
else
    foreach ( $rss_items as $item ) : ?>
<?php if ( false === mb_check_encoding ( $item->get_description(), ASCII ) ) continue; ?>
<div class="post"><div style="padding:8px;float:right"><a rel="nofollow" class="shot" href="<?php echo $item->get_permalink(); ?>" title="<?php echo $item->get_title(); ?>"><img src="http://images.websnapr.com/?url=<?php echo $item->get_permalink(); ?>&size=s&nocache=15" border="none" /></a></div><h2><a rel="nofollow" href="<?php echo $item->get_permalink(); ?>" title="<?php echo $item->get_title(); ?>"><?php echo $item->get_title(); ?></a></h2><div class="entry"><?php echo $item->get_description(); ?></div></div>
    <?php endforeach; ?>

</div>
	</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>